package com.dbb.trade.service.shipment;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dbb.trade.dao.company.ShipmentDao;
import com.dbb.trade.entity.shipment.Shipment;

@Component
@Transactional(readOnly = true)
public class ShipmentManager {

	private static Logger logger = LoggerFactory.getLogger(ShipmentManager.class);

	@Autowired
	private ShipmentDao shipmentDao;
	
	@Transactional(readOnly = false)
	public Shipment save(Shipment shipment) {
		logger.info("save {}", shipment);
		return shipmentDao.save(shipment);
	}

	public List<Shipment> findAll() {
		return (List<Shipment>) shipmentDao.findAll();
	}
	
	public Page<Shipment> findAll(Pageable pageable) {
		return shipmentDao.findAll(pageable);
	}
	
	@Transactional(readOnly = false)
	public void delAll() {
		shipmentDao.deleteAll();
	}
	
	public Shipment findByCode(String string) {
		return shipmentDao.findByCode(string);
	}

}
